# 代码所有：cxw
# 开发时间：2021/11/13 22:54
# import json
# def greet():
#     filename="uses.json"
#     try:
#         with open(filename) as file_ob:
#             users=json.load(file_ob)
#     except FileNotFoundError:
#         username=input("请输入你的名字：")
#         with open(filename,"w") as file_obj:
#             json.dump(username,file_obj)
#         print("我们将会记住你，并且返回你 ",username)
#     else:
#         print(users)
# greet()

#重构
import json
def greet_stroged_users():
    filenames = "uses.json"
    try:
        with open(filenames) as files_obj:
            uses=json.load(files_obj)
    except FileNotFoundError:
        return None
    else:
        print(uses)
def greet_unstroged_users():
    username=greet_stroged_users()
    if username:
        print("欢迎回来，",username)
    else:
        username=input("请输入你的名字：")
        filename="uses.json"
        with open(filename,"w") as files:
            json.dump(username,files)
            print("我们将会记住你，并且返回你，",username)
greet_unstroged_users()